//
//  AnimationListController.m
//  Objc进阶Demo
//
//  Created by Don't update on 2018/7/17.
//  Copyright © 2018年 Don't update. All rights reserved.
//

#import "AnimationListController.h"
#import "WeiboViewController.h"
#import "LoginAnimationController.h"
#import "DrawBoardController.h"
#import "LottieController.h"
@interface AnimationListController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSArray *list;
@end

@implementation AnimationListController


-(NSArray *)list{
    if (_list == nil) {
        _list = [[NSArray alloc]initWithObjects:@"账号登录动画",@"类似微博个人主页动画实现",@"绘画板",@"Lottie动画", nil];
    }
    return _list;
}

-(UITableView *)tableView{
    if (_tableView == nil) {
        _tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        [self.view addSubview:_tableView];
    }
    return _tableView;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _list.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *animationCell =@"animationCell_id";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:animationCell];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:animationCell];
    }
    cell.textLabel.text = _list[indexPath.row];
    return  cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([_list[indexPath.row] isEqualToString:@"账号登录动画"]) {
        LoginAnimationController *loginVC = [[UIStoryboard storyboardWithName:@"LoginAnimationController" bundle:[NSBundle mainBundle]]instantiateViewControllerWithIdentifier:@"LoginAnimationController"];
        [self.navigationController pushViewController:loginVC animated:YES];
    }
    if ([_list[indexPath.row] isEqualToString:@"类似微博个人主页动画实现"]) {
        WeiboViewController *weiboVC = [[WeiboViewController alloc]init];
        [self.navigationController pushViewController:weiboVC animated:YES];
    }
    if ([_list[indexPath.row] isEqualToString:@"绘画板"]) {
        DrawBoardController *drawVC = [[DrawBoardController alloc]init];
        [self.navigationController pushViewController:drawVC animated:YES];
    }
    if([_list[indexPath.row]isEqualToString:@"Lottie动画"]){
        LottieController *lotVC = [[LottieController alloc]init];
        [self.navigationController pushViewController:lotVC animated:YES];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self list];
    [self tableView];
}



@end
